package cn.yinuo.website.medicine.web;


import cn.yinuo.website.common.bean.BaseQueryVo;
import cn.yinuo.website.common.config.JsonParam;
import cn.yinuo.website.common.util.PageQueryUtils;
import cn.yinuo.website.medicine.entity.MedicineProblem;
import cn.yinuo.website.medicine.service.IMedicineProblemService;
import com.baomidou.mybatisplus.plugins.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author shiyang
 * @since 2019-05-26
 */
@RestController
@RequestMapping("/api/medicine/problems")
@Api(description="药品相关问题")
public class MedicineProblemController {

    @Autowired
    private IMedicineProblemService medicineProblemService;
    @ApiOperation(value = "新增" ,  notes="新增")
    @PostMapping
    public MedicineProblem create(@RequestBody MedicineProblem medicineProblem){
        return medicineProblemService.add(medicineProblem);
    }

    @ApiOperation(value = "修改" ,  notes="修改")
    @PutMapping
    public MedicineProblem update(@RequestBody MedicineProblem medicineProblem){
        return medicineProblemService.modify(medicineProblem);
    }

    @ApiOperation(value = "删除" ,  notes="删除")
    @DeleteMapping("{id}")
    public void delete(@PathVariable("id") String id){
        medicineProblemService.delete(id);
    }

    @ApiOperation(value = "根据id查询" ,  notes="根据id查询")
    @GetMapping("{id}")
    public MedicineProblem query(@PathVariable("id") String id){
        return medicineProblemService.queryById(id);
    }

    @GetMapping()
    @ApiOperation("分页查询")
    @ApiImplicitParam(name = "queryVo",dataType = "BaseQueryVo" ,paramType = "query")
    public Page<MedicineProblem> page(@JsonParam BaseQueryVo<MedicineProblem> queryVo){
        return medicineProblemService.selectPage(queryVo.getPageObj(),PageQueryUtils.getWrapper(queryVo));
    }
}
